#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main()
{
	pid_t id = fork();
	if(id == 0) 
	{
		//子进程,循环5次子进程后，就停了
		int cnt = 5;
		while(cnt)
		{
			printf("I am child, cnt: %d, pid: %d\n",cnt,getpid());
			sleep(1);
			cnt--;
		}
	}
	else
	{
		//parent
		while(1)
		{
			printf("I am parent, running always!, pid: %d\n", getpid());
			sleep(1);
		}
	}
	return 0;
}


